﻿using Autofac;
using Sodao.Demo.Core.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Sodao.Demo.Domain
{
    public static class AutoFacExtensions
    {
        /// <summary>
		/// DI 容器注入
		/// </summary>
		/// <param name="autoFacManage"></param>
		public static void AddDomainDI(this AutoFacManage autoFacManage)
        {
            autoFacManage.Register(builder =>
            {
                Assembly assembliesRepository = Assembly.Load("Sodao.Demo.Domain");

                builder.RegisterAssemblyTypes(assembliesRepository).Where(t => t.Name.EndsWith("Repository")).AsImplementedInterfaces().SingleInstance();

            });
        }
    }
}
